home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
BBS
/
MUBBS
/
MUBBS etc.cpt
/
Module Source
/
E-mail
/
DisplayEmail.c
< prev
next >
Wrap
Text File
|
1991-11-21
|
4KB
|
135 lines
/* *********************************************************************************
MODULE: DisplayEmail Module
DESCRIPTION: This DisplayEmail Module is a simple module for MUBBS, the
Multi-User Bulliten Board System Software.
AUTHOR: Noam Freedman
Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
This program source code and it's compiled version IS NOT IN THE
PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
regarding use of this program source code and it's compiled version.
Revision History:
============================================================
8/26/91 - Started programming
11/ 4/91 - Edited for release
============================================================
******************************************************************************** */
#define INMAIN
#include "MUBBS Module.h"
#include "Email.h"
#include <SetUpA4.h>
/* my globals for this module */
pascal void main (mode1,G1,P1)
int mode1;
struct GS *G1;
Ptr P1;
{
Handle temph;
float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
mode[u]=mode1; /* set up our mode so that you can read it anywhere */
switch (mode[u]) { /* any un-handled modes return error from this module */
case 3:
loademail(P1); /* mode 3 because we are passed a pointer */
G->moduleresult=0;
break;
case 98:
versionck(version); /* just return after this call, don't modify anything */
break;
case 0:
strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
break;
default:
G->moduleresult=1; /* return bad code */
};
HUnlock(temph); /* unlocks this module, do this ! */
RestoreA4(); /* call this when you are all done */
}
loademail(S)
struct LoadStruct *S;
{
char pad[100]; /* this is a fix for a problem */
struct MsgStruct MsgInfo;
struct FixStruct fixinfo;
FILE *fp_headers, *fp_data;
int i = 0, r, num, b,x;
char ch;
size_t fix;
if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
strcpy(MsgInfo.FromUser, S->FromUser[S->choice] );
strcpy(MsgInfo.ToUser, G->username[u]);
strcpy(MsgInfo.title, S->title[S->choice]);
MsgInfo.status= S->status[S->choice];
strcpy(MsgInfo.NetAddress, S->NetAddress[S->choice]);
MsgInfo.offset= S->offset[S->choice];
MsgInfo.length= S->length[S->choice];
strcpy(MsgInfo.DateSent, S->DateSent[S->choice]);
send("]Msg : %i of %i]",S->choice,S->numemail);
send("Title: %s]",MsgInfo.title);
send("From : %s]",MsgInfo.FromUser);
send("Date : %s]",MsgInfo.DateSent);
send(G->CR[u]);
if ( (fp_data = fopen(":msgs:email.data","r")) == NULL )
{
send("]Can't open the file: %s]",":msgs:email.data");
num = 3;
pause();
}
else
{
fseek( fp_data , S->offset[S->choice] , SEEK_SET );
fix=sizeof(fixinfo);
x = S->length[S->choice] - (fix + 2); /* don't read the "fix" stuff */
/* sizeof +1 and S->length -1 actually */
if(x>32000) x=32000;
if(x<0) x=0;
while ( i <= x )
{
i=i+1;
if ((b = fgetc(fp_data)) != EOF)
{
if (G->okcancel[u]) if (G->cancel[u]) break; /* check for cancel press */
ch = b & 0xFF;
if ((ch == 0x0A) || (ch == 0x0D)) send(G->CR[u]);
else G->out(ch);
}
else
{
i = x+1;
}
}
fclose(fp_data);
num = 0;
}
byebye:
S->result=num;
return;
}